package threads;

public class PrintAZ026Test_ObjectWait {
    public static void main(String[] args) {
        final Object mLock = new Object();
        Thread t1 = new Thread(() -> {
            for (int i = 'A'; i <= 'Z'; i++) {
                synchronized (mLock) {
                    System.out.println((char) i);
                    mLock.notifyAll();
                    try {
                        mLock.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                synchronized (mLock){
                    mLock.notifyAll();
                }
            }
        });
        Thread t2 = new Thread(() -> {
            for (int i = 1; i <= 26; i++) {
                synchronized (mLock) {
                    System.out.println(i);
                    mLock.notifyAll();
                    try {
                        mLock.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
            synchronized (mLock){
                mLock.notifyAll();
            }
        });
        t1.start();
        t2.start();
    }
}
